package com.colin.aiyi.ui.login;

import com.colin.aiyi.dao.ImpxUtils.ImpGetUserInfo;
import com.colin.aiyi.dao.ImpxUtils.ImpLogin;
import com.colin.aiyi.dao.ImpxUtils.ImpUpdatePassword;
import com.colin.aiyi.entity.response.LoginResponse;
import com.colin.aiyi.entity.User;
import com.colin.aiyi.presenter.AbsP;

/**
 * Created by hl on 2017/6/9.
 */

public class ImpPLogin extends AbsP {
    User user;
    private boolean isRequest=false;

    @Override
    public void onSuccess(Object t) {
        isRequest=false;
        LoginResponse login= (LoginResponse) t;
        if (login.getCode()==200){
            user=login.getData();
            user_getUserInfo(user);
        }else {
            sendMsgToView(login);
        }
    }

    @Override
    public <User> void login_login(User user) {
        if (isRequest)
            return;
        iService=new ImpLogin();
        iService.getObject(this,user);
        isRequest=true;
    }

    @Override
    public <User> void user_getUserInfo(User user) {
        super.user_getUserInfo(user);
        iService=new ImpGetUserInfo();
        iService.getObject(user);
    }


    @Override
    public <V> void user_updatePassword(V v) {
        super.user_updatePassword(v);
        iService=new ImpUpdatePassword();
        iService.getObject(v);
    }
}
